#!/bin/sh

# Enable on boot
/etc/init.d/wrtbwmon enable

# Configure our cron
if [ -d "/etc/crontabs" ]; then
  echo "PATH=/usr/sbin:/usr/bin:/sbin:/bin" > /etc/crontabs/wrtbwmon
  echo "* * * * * /usr/sbin/wrtbwmon update /tmp/usage.db" >> /etc/crontabs/wrtbwmon
  echo "0 * * * * /usr/sbin/wrtbwmon publish /tmp/usage.db /tmp/usage.htm" >> /etc/crontabs/wrtbwmon
fi
/etc/init.d/cron reload

# Symlink to our webdir
if [ -d "/var/www/html" ]; then
  ln -s /tmp/usage.htm /var/www/html/usage.htm
elif [ -d "/www" ]; then
 ln -s /tmp/usage.htm /www/usage.htm
fi

exit 0
